package com.android.car.screensaver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class ScreenSaverReceiver extends BroadcastReceiver {

    private static final String TAG = "ScreenSaverReceiver";
    private static final String ACTION_SCREENSAVER_ON = "com.android.intent.action.RK_SCREENSAVERON";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "[onReceive] action: " + intent.getAction());
        if (ACTION_SCREENSAVER_ON.equals(intent.getAction())) {
            // launch the screen-saver activity
            Intent screensaver = new Intent(context, ScreenSaver.class);
            screensaver.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(screensaver);
        }
    }

}
